Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat tags.script like an HTML dependency inside of JSXTag #27

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cpsievert
Copy link
Collaborator

Closes #26

@cpsievert cpsievert requested a review from wch April 6, 2022 23:02
@cpsievert cpsievert force-pushed the jsx-child-script-tag branch from a458540 to 8168b49 Compare April 6, 2022 23:04
@cpsievert cpsievert force-pushed the jsx-child-script-tag branch from 8168b49 to bde4d1b Compare April 7, 2022 19:14
@cpsievert
Copy link
Collaborator Author

One thing about this that makes me feel like it's not a terrible solution: the way dynamic UI currently renders <script> tags is via jQuery().html() which also hoists them up into the <head> of the document (as we learned in #19). So, if someone has a <script> tag that happens to depend on it being located in the body, it likely won't work for dynamic UI.

# React.createElement("script") won't invoke it's contents in the same
# way ordinary HTML tags do, but we can circumvent that by 'hoisting' it
# as head_content.
metadata_nodes.append(head_content(x))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we move forward with this, we'll want to have something like head_content(x, dedup=False) to make sure the <script> executes everytime, as it normally would in normal HTML

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tags.script() doesn't execute when it's a child of a JSXTag
1 participant